package com.xbkj.pgrp.server.model.app;

import com.xbkj.pgrp.server.dataproxy.EmployeeDataProxy;
import lombok.Getter;
import lombok.Setter;
import xyz.erupt.annotation.Erupt;
import xyz.erupt.annotation.EruptField;
import xyz.erupt.annotation.PreDataProxy;
import xyz.erupt.annotation.sub_field.Edit;
import xyz.erupt.annotation.sub_field.EditType;
import xyz.erupt.annotation.sub_field.View;
import xyz.erupt.annotation.sub_field.sub_edit.Search;
import xyz.erupt.upms.model.base.HyperModel;

import javax.persistence.*;
import java.util.Set;

/**
 * 项目成员信息
 */
@Erupt(
    name = "员工信息"
)
@Entity
@Table(name = "pgrp_employee")
@Getter
@Setter
@PreDataProxy(EmployeeDataProxy.class)
public class Employee extends HyperModel {
    @EruptField(
            views = @View(title = "姓名"),
            edit = @Edit(title = "姓名", notNull = true, search = @Search(vague = true))
    )
    @Column(nullable = false, length = 255)
    private String name;

    @EruptField(
            views = @View(title = "工号"),
            edit = @Edit(title = "工号", notNull = true, search = @Search(vague = true)),
            sort = 1
    )
    @Column(nullable = false, length = 255)
    private String no;

    @OneToMany
    @JoinColumn(name = "employee_id")
    @EruptField(
            views = @View(title = "请假信息"),
            edit = @Edit(title = "请假信息", type = EditType.TAB_TABLE_ADD)
    )
    private Set<Absence> absences;
}
